<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>备忘录</title>
    <script src="./js/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="message" placeholder="请输入消息"/>
        <button @click="add">添加</button>
        <ul v-show="messages.length>0">
            <li v-for="(item, index) in messages">
                {{item}}<button @click="messages.splice(index, 1)">删除</button>
            </li>
            <!-- <li>今天中饭吃了11元</li>
            <li>李四打游戏不带我</li> -->
        </ul>
        <p v-show="messages.length==0">未添加备忘信息</p>
    </div>
</body>
</html>
<script>
    new Vue({
        el: '#app',
        data: {
            message: '',
            messages: []
        },
        methods: {
            add() {
                this.messages.push(this.message)
                this.message = ''
            }
        }
    })
</script>